/*
 * @Description: 好友相关接口
 * @Author: Yong
 * @Date: 2021-10-06 16:59:27
 * @LastEditTime: 2021-10-09 22:04:57
 */

import Axios from '@utils/axios'
import { HttpResponse, applyFriendParams} from './interface'

export class FriendsService {

    /**
     * @description 好友申请
     * @return {HttpResponse} result
     */
    static async applyFriend (params: applyFriendParams): Promise<HttpResponse> {
        return Axios({
            method: 'post',
            url: '/friends/apply',
            data: params,
        })
    }

    /**
     * @description 获取好友申请列表
     * @return {HttpResponse} result
     */
    static async getApplyFriendsList (userID: string): Promise<HttpResponse> {
        return Axios({
            method: 'get',
            url: '/friends/getApplyFriendsList',
            params: { U_UserID: userID },
        })
    }

    /**
     * @description 拒绝好友申请
     * @return {HttpResponse} result
     */
    static async refuseFriend (uid: string, fid: string): Promise<HttpResponse> {
        return Axios({
            method: 'delete',
            url: '/friends/delFriends',
            data: { U_UserID: uid, U_FriendID: fid },
        })
    }

    /**
     * @description 同意好友申请
     * @return {HttpResponse} result
     */
    static async agreeFriend (uid: string, fid: string): Promise<HttpResponse> {
        return Axios({
            method: 'put',
            url: '/friends/updateFriendStates',
            data: { U_UserID: uid, U_FriendID: fid },
        })
    }

}